#!/usr/bin/perl -ws
@method_lines = ();
@super_method_lines = ();
while (defined ($line = <>)) {
	$orig_line = $line;
  $line =~ s/^[\t ]*//g;
  $line =~ s/[\t ]*[\r\n]*$//g;
  $line =~ s/[\t ][\t ]*/ /g;
  $new_line = $line;
  $new_line =~ s/private *//;
  $new_line =~ s/protected *//;
  $new_line =~ s/static *//;
  $new_line =~ s/public *//;
  $new_line =~ s/volatile *//;
  $new_line =~ s/final *//;
  ($type, $varname, $rest) = split (' ', $new_line);
  if ($varname =~ /\[/) {
    $type .= $varname;
    ($varname, $rest) = split (' ', $rest);
  };
  if (($line =~ /String/) && ($line !~ /null/)) {
    if ($line =~ /=/) {
      $line .= " null";
    } else {
      $line .= " = null";
    };
  };
  $is_boolean = 0;
  if ($line =~ /boolean/i) {
    $is_boolean = 1;
    if (($line !~ /false/) && ($line !~ /true/)) {
      if ($line =~ /=/) {
        $line .= " false";
      } else {
        $line .= " = false";
      };
    };
  };
  if ($line !~ /;/) {
    $line .= ";";
  };
  $varname =~ s/;//g;
  $first_letter = substr ($varname, 0, 1);
  $rest = substr ($varname, 1, length ($varname));
  $cap_first_letter = $first_letter;
  $cap_first_letter =~ tr/a-z/A-Z/;
  while (($pos = index ($rest, "_")) > 0) {
    $begin = substr ($rest, 0, $pos);
    $end = substr ($rest, $pos + 1);
    $first_end = substr ($end, 0, 1);
    $end_rest = substr ($end, 1, length ($end));
    $cap_first_first_end = $first_end;
    $cap_first_first_end =~ tr/a-z/A-Z/;
    $rest = $begin . $cap_first_first_end . $end_rest;
  };
  print "$orig_line";
  &add_method_lines(\@method_lines, $is_boolean, 0);
  if (defined($s) && ($s == 1)) {
    &add_method_lines(\@super_method_lines, $is_boolean, 1);
  };
};

print (@method_lines);
if (defined($s) && ($s == 1)) {
  print (@super_method_lines);
};

sub  add_method_lines {
  my($ptr_method_lines, $is_boolean, $is_super) = @_;
  push (@$ptr_method_lines,   "    public void set$cap_first_letter${rest}($type $varname) {\n");
  if ($is_super == 0) {
    push (@$ptr_method_lines,   "        this.$varname = $varname;\n");
  } else {
    push (@$ptr_method_lines,   "        super.set$cap_first_letter${rest}($varname);\n");
  };
  push (@$ptr_method_lines, "    }\n");
  push (@$ptr_method_lines, "\n");
  if ($is_boolean) {
    push (@$ptr_method_lines, "    public $type is$cap_first_letter${rest}() {\n");
  } else {
    push (@$ptr_method_lines, "    public $type get$cap_first_letter${rest}() {\n");
  };
  if ($is_super == 0) {
    push (@$ptr_method_lines,   "        return ($varname);\n");
  } else {
		if ($is_boolean) {
			push (@$ptr_method_lines,   "        return (super.is$cap_first_letter${rest}());\n");
		} else {
			push (@$ptr_method_lines,   "        return (super.get$cap_first_letter${rest}());\n");
		};
  };
  push (@$ptr_method_lines, "    }\n");
  push (@$ptr_method_lines, "\n");
}

exit 0
